package org.bonorsoft.modules.dingding.mapper;

import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bonorsoft.modules.dingding.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * @Description: 角色
 * @Author: WilliamYe
 * @Date:   2020-11-13
 * @Version: V1.0
 */
public interface SysRoleMapper extends BaseMapper<SysRole> {

    boolean removeByIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);

    /**
     * 根据用户ID查询角色
     *
     * @param userid 用户ID
     * @return 角色列表
     */
    public List<SysRole> selectRolesByUserId(String userid);

    @Select("select r.id, r.data_scope from sys_role r left join sys_user_role ur on r.id = ur.id where ur.user_id = #{userid}")
    List<SysRole> getRolesByUserId(String userid);
}
